home *** CD-ROM | disk | FTP | other *** search
- /******************************************************************************
- *
- * NSSDC/CDF CDFbrowse.
- *
- * Version 2.0, 9-Mar-92, ST Systems (STX)
- *
- * Modification history:
- *
- * V1.0 24-Jan-91, D Grogan, H Leckner Original version (for CDF V2.0).
- * V1.1 30-Jan-91, J Love Allocated enough space for menu of
- * attribute entries for a variable.
- * V1.2 26-Mar-91, J Love Cast menu text pointer to void and
- * added include of "ctype.h". Used
- * toupper the safe way and added a
- * definition for toupper if SunOS
- * 4.0.3.
- * V1.3 4-Jun-91, S Sudarsan Improved File/Directory handling
- * with file_names.c
- * V1.4 25-Jun-91, J Love Removed TITLE display unless NSSDC
- * standard configuration. Added QOP.
- * V1.5 3-Aug-91, J Love Cray/UNICOS port. Use 'Exit' &
- * 'ExitBAD'. Fixed no-can-do window.
- * V2.0 9-Mar-92, J Love Modified for IBM-PC port. CDF V2.2
- * H Leckner
- *
- ******************************************************************************/
-
- #ifdef vms
- #include <stdio.h>
- #include <descrip.h>
- #include <rmsdef.h>
- #include <climsgdef.h>
- #endif
-
- #if defined(unix)
- #include <sys/types.h>
- #include <sys/stat.h> /* V1.3 */
- #endif
-
- #include <ctype.h> /* V1.2 */
-
- #include "cdfdist.h"
- #include "wfl.h"
- #include "kb_def.h"
- #include "dynaptr.h" /* dynamic array macros */
- #include "utility.h"
-
- #define CDFBROW /* For global/external variables. */
- #include "cdfbrow.h"
-
- #if defined(__MSDOS__)
- extern unsigned _stklen = 50000U;
- #endif
-
- #define CLEAN_PAGE(pagePtr,np,string) {long j; \
- for(j=0; j<np; j++) \
- strcpy(pagePtr[j],string); \
- strcpy(pagePtr[np-1],""); \
- }
-
- /* Constants for the screen layout */
-
- #define TITLE_ROW 2 /* Title box location */
- #define TITLE_COL 2
-
- #define HEADER_ROW 4 /* Header box location */
- #define HEADER_COL 1
-
- #define ATTMEN_ROW 4 /* Attributes menu location and height */
- #define ATTMEN_COL 24
- #define ATTMEN_HT 8
-
- #define VARMEN_ROW 9 /* Variables menu location and height */
- #define VARMEN_COL 6
- #define VARMEN_HT 8
-
- /* Other constants */
-
- #define HIGHLIGHT 1 /* For call to WFL_popup_menu() */
- #define HIGHLIGHT_OFF 0
-
- #define BEEP 1 /* For call to MESS_display() */
- #define NOBEEP 0
-
- #define HEADER_LINES SCREEN_HEIGHT
- #define TITLE_LINES 6
-
- #define VARDEF 1 /* selector for 2 kinds of variable displays */
- #define VARVAL 2
- #if defined(__MSDOS__)
- #define VARVAL_LINES (752) /* maximum items allowed in varVal display */
- #else
- #define VARVAL_LINES (5003)
- #endif
- #define CDF_IS_CLOSED 0
-
- #define MAXNAMELEN 512 /* Concerning file_names and dlist() */
- #define MAXFILES 2048
- #define TRUNC_NONE " "
- #define TRUNC_VER ";"
- #define TRUNC_EXT "."
-
- /* Defining id's for all menus & forms */
-
- #define selectDirectoryFormId -1
- #define selectRecordFormId -2
-
- #define transientMenuId 0
- #define filesMenuId 1
- #define filenotfoundMenuId 2
- #define browseMenuId 3
- #define attrMenuId 4
- #define varMenuId 5
- #define varDefMenuId 6
- #define attrEntriesMenuId 7
- #define mainHelpMenuId 8
- #define showMenuKeysMenuId 9
- #define showFormKeysMenuId 10
- #define helpInContextMenuId 11
- #define generalMenusId 12
- #define generalFormsId 13
- #define varValMenuId 14
- #define attrEntryElemsMenuId 15 /* new menu, v2.0 */
- #define copyrightMenuId 16 /* new menu, v2.0 */
- #define menuMapMenuId 17 /* new menu, v2.0 */
-
- /* the cdf_id is a global variable */
-
- static long cdf_id = 0;
- /******************************************************************************
- * BuildSearchSpec.
- ******************************************************************************/
-
- void BuildSearchSpec (path_spec, search_spec)
- char *path_spec;
- char *search_spec;
- {
- strcpy (search_spec, path_spec);
-
- if (strlen(search_spec) > 0)
- if (IsDir(search_spec))
- AppendToDir (search_spec, "*.cdf");
- else
- strcat (search_spec, ".cdf");
- else
- strcpy (search_spec, "*.cdf");
-
- return;
- }
-
- /******************************************************************************
- * BuildWFLlist.
- ******************************************************************************/
-
- void BuildWFLlist (nlines, lines1, list)
- long nlines;
- char **lines1;
- char ***list;
- {
- int i;
-
- *list = (char **) malloc ((nlines+1) * sizeof(char *));
-
- for (i = 0; i < nlines; i++) {
- (*list)[i] = (char *) malloc (strlen(lines1[i]) + 1);
- strcpy ((*list)[i], lines1[i]);
- }
-
- (*list)[i] = (char *) malloc ((size_t) 1);
- strcpy ((*list)[i], "");
-
- return;
- }
-
- /******************************************************************************
- * FreeWFLlist.
- ******************************************************************************/
-
- void FreeWFLlist (list)
- char **list;
- {
- int i;
-
- for (i = 0; /*no-terminator*/; i++) {
- if (list[i][0] == '\0') { /* Null-string ends WFL list. */
- free (list[i]);
- free (list);
- return;
- }
- else
- free (list[i]);
- }
- }
-
- void exitProgram ()
- {
- /* If it is open, close the CDF.
- * cdf_id is static global variable.
- */
- if (cdf_id != CDF_IS_CLOSED) cdfCloseQuit ();
-
- /* Close the interface package */
- WFL_close ();
- Exit;
- } /* end exitProgram */
-
-
- int interrupt_check (keyWas, menu_id)
- int keyWas;
- int menu_id;
- {
- /* This function should be called after every return
- * from a menu or a form to see if the user has
- * struck one of the interrupt keys --
- * HELP
- * CONTEXT_HELP
- * QUIT (the program EXIT command)
- */
-
- int saveRow;
- int saveCol;
- static char YesNo[4] = "No";
-
- /* Save location of cursor from last menu or form */
- saveRow = menu_bar_last_at_row (0);
- saveCol = menu_bar_last_at_col (0);
-
- switch (keyWas) {
- case KBM_HELP:
- helpMenu (menu_id);
- break;
-
- case KB_CONTEXT_HELP:
- explain (saveRow+2, saveCol+2, menu_id);
- break;
-
- case KBM_QUIT:
- GENERIC_form (" EXIT the program (Y/N) ? ",
- YesNo, 3, 0, 0);
- if ((islower(YesNo[0]) ?
- toupper(YesNo[0]) : YesNo[0]) == 'Y') /* V1.2 */
- exitProgram ();
- break;
- default:
- break;
- }
-
- /* restore location of cursor as it was on function entry. */
- menu_bar_last_at_row (saveRow);
- menu_bar_last_at_col (saveCol);
-
- return;
-
- } /* end interrupt_check */
-
-
- int explain (row, col, menu_id)
- int row;
- int col;
- int menu_id;
- {
- long int selection;
- static char *explainGeneralMenus[] =
- {
- " -- Menus -- ",
- " ",
- " Menus are windows containing selection lists. ",
- " A reverse-video bar will show you the current selection ",
- " in a menu. Use the UP and DOWN arrow keys to move the ",
- " menu bar. To move the bar full menu \"pages\" press the ",
- " PAGE-DOWN (D) and the PAGE-UP (U) keys. ",
- " Press the SELECT (RETURN) key to choose a menu item.",
- " When you want to leave a menu, use the KILL key (CTRL-K). ",
- " (See also \"Menu Keys\" in the main help menu.) ",
- " ",
- " Special Note: Some windows do NOT have reverse-video bars. ",
- " These are information windows and there is nothing to select ",
- " from them. However, they may sometimes contain multiple pages ",
- " of information. The window message will tell you when this ",
- " is the case. For example, the window may say \"12 Attributes\" ",
- " when only 8 are displayed. ",
- " Or, you might see \" -- more -- \" as you do in this window. ",
- " In these situations, strike the PAGE-DOWN key (D) TWICE to ",
- " to see more of the window, and continue striking the PAGE-DOWN key ",
- " until you reach the end of an information window. ",
- " -- more -- ",
- " ",
- " This demonstrates the use of the PAGE-DOWN key to see more. ",
- " To go back up, press PAGE-UP (U) twice.",
- " ",
- " (This is the end of information about Menus. CTRL-K to quit.) ",
- " ",
- "",
- };
-
- static char *explainGeneralForms[] =
- {
- " -- Forms -- ",
- " ",
- " Forms are for your input of data, often just one item. ",
- " ",
- " Forms will have one or more fields for data entry. ",
- " The prompt for a field will describe what is needed. ",
- " Just type normally in the form field. ",
- " Press the RETURN key to SELECT (or accept) the item. ",
- " ",
- " Be sure to see the main help selection named \"Form Keys\", ",
- " especially the line-editing section, for more help with forms. ",
- " ",
- "",
- };
-
- static char *explainDirNameForm[] =
- {
- " -- Browse Directory Prompt -- ",
- " ",
- " Enter any legal VMS directory path specification in this ",
- " one-item input form and press RETURN. ",
- " ",
- " You may include a CDF name, or partial name, in the path ",
- " if you wish to see only certain CDFs. ",
- " CDFbrowse will append \"*.cdf\" to the name you give and ",
- " search the named directory for *.cdf type files. ",
- " Therefore, if the name you specify is a VMS logical-name, ",
- " end the name with a colon, as in \"LOGICAL_PATH:\" .",
- " ",
- " If there are CDFs on the directory, you will see ",
- " the CDFs Menu containing a list of those CDFs. ",
- " ",
- " Examples:",
- " ncf_cdaw_user:[cdaw8cdf.eventa] ",
- " [] ",
- " logical_path: ",
- " []cac_sst_blended" ,
- " ",
- " (CTRL-K to quit.) ",
- "",
- };
-
- static char *explainRecordNumForm[] =
- {
- " -- CDF Record Number Prompt -- ",
- " ",
- " You will see this prompt after selecting a variable in the ",
- " Variable Values Menu.",
- " ",
- " Enter an integer from 1 to the number of records in the CDF ",
- " and press RETURN. ",
- " ",
- " You will then see the values of the current variable for ",
- " for that record displayed in an information window.",
- " ",
- " (CTRL-K to quit.) ",
- "",
- };
-
- static char *explainFileMenu[] =
- {
- " -- CDFs Menu -- ",
- " ",
- " The CDFs Menu shows you the names of the CDFs on the ",
- " directory you selected in the opening 'Browse Directory' prompt.",
- " ",
- " Select a CDF from the menu. First, the CDF header ",
- " will be displayed, and then the Browser Menu will appear. ",
- " ",
- "",
- };
-
- static char *explainBrowserMenu[]=
- {
- " -- Browser Menu -- ",
- " ",
- " You'll see this menu after selecting a CDF from the CDFs Menu.",
- " ",
- " Choose an item on the Browser to go to other menus for ",
- " more information about the current CDF. ",
- " For instance, choose \"Attribute Definitions\" to go to ",
- " the Attributes Menu. ",
- " ",
- "",
- };
-
- static char *explainAttrMenu[] =
- {
- " -- Attributes Menu -- ",
- " ",
- " Here you see all the attributes defined for the current CDF. ",
- " You will see each attribute's name, number of entries, and scope. ",
- " ",
- " Select an attribute to see all the entries for that attribute. ",
- " ",
- "",
- };
-
- static char *explainVarOfAttMenu[] =
- {
- " -- Entries Menu -- ",
- " ",
- " You'll see this menu after selecting from the Attribute Menu. ",
- " ",
- " In this menu, all entries of the chosen attribute are shown. ",
- " If the attribute is global in scope you'll see {global}, ",
- " otherwise the name of the variable to which it refers is shown.",
- " You will also see each entry's datatype and its number of elements, ",
- " followed by the content of the first element. (If it's a string, ",
- " you'll see all of it that can fit the screen.) If more elements ",
- " exist, not shown, you'll see {...} at the end. ",
- " ",
- " Select an entry to see all the additional elements, or to see a ",
- " string-type entry displayed vertically, character-by-character.",
- " ",
- "",
- };
-
- static char *explainElementsMenu[] =
- {
- " -- Elements List -- ",
- " ",
- " You'll get to this list from one of two places, either from the ",
- " Entries Menu for attributes, or from the Variable's Entry's Menu. ",
- " ",
- " This list shows all the elements of an attribute entry in a ",
- " vertical format. The first line tells whether the entry is global ",
- " or variable in scope, and tells the datatype. ",
- " Then the elements for the entry are listed. ",
- " ",
- " There is nothing to select from this listing. ",
- " ",
- "",
- };
-
- static char *explainVarMenu[] =
- {
- " -- Variables Menu -- ",
- " ",
- " This menu shows you the variables defined for the current CDF. ",
- " ",
- " Select a variable from this menu to see EITHER the values of ",
- " that variable's attributes (the Variable Definition), or ",
- " the actual data values of the variable (Variable Values). ",
- " ",
- " Which of these you see depends on what you chose in the ",
- " Browser Menu -- Variable Definitions or Variable Values.",
- " ",
- "",
- };
-
- static char *explainAttOfVarMenu[] =
- {
- " -- Attributes of a Variable -- ",
- " ",
- " You'll see this menu after selecting a variable from the Variable ",
- " Definitions Menu. ",
- " ",
- " Here, all entries are shown for the attributes of a given variable. ",
- " You will also see each entry's datatype and its number of elements, ",
- " followed by the content of the first element. (If it's a string, ",
- " you'll see all of it that can fit the screen.) If more elements ",
- " exist, not shown, you'll see {...} at the end. ",
- " ",
- " Select an entry to see all the additional elements, or to see a ",
- " string-type entry displayed vertically, character-by-character.",
- " ",
- "",
- };
-
-
- static char *explainVarValMenu[]=
- {
- " -- Values of a Variable -- ",
- " ",
- " In this listing, data values are shown for the selected variable ",
- " for the record chosen at the Record Number Prompt. The format of ",
- " the listing will look something like this example:",
- " ",
- " ( 50) 203:[ 2, 7]= datum-value ",
- " ",
- " The number in parentheses, (50), is the item count, which tells you ",
- " where you are in the displayed list. The next number, which is ",
- " followed by a colon, 203:, is the CDF record number. The numbers ",
- " in brackets, [ 2, 7], are indexes to dimensions for the CDF. ",
- " ",
- " If you see an asterisk in place of a record or dimension index ",
- " number, it is because the variance is false for the record or ",
- " for the dimension. For example, ",
- " ",
- " ( 50) *:[ *, 7]= datum-value ",
- " ",
- " <more... PAGE-DOWN (D) twice> ",
- " ",
- " ",
- " The order of indexes in the listing will correspond to the ",
- " storage for of the CDF, either ROW_MAJOR or COL_MAJOR. ",
- " ",
- " If a \"FORMAT\" attribute exists for the variable, the FORMAT string ",
- " is used to format values. ",
- " ",
- " If the variable is an \"EPOCH\" it will be shown not as a real-number ",
- " but translated to a readable form, like \"03-Dec-1990 11:25:07.000\"",
- " ",
- " At present, no more than 5000 lines will be displayed for a variable. ",
- " ",
- " The Values of a Variable listing is not a selection menu. ",
- " Use PAGE-DOWN and PAGE-UP keys to view long lists. ",
- " ",
- " (CTRL-K to quit this window)",
- " ",
- "",
- };
-
- static char *explainNope[]=
- {
- " ",
- " Sorry, there is no further explanation for the current window. ",
- " ",
- "",
- };
-
- int saveRow, saveCol;
- int keyWas;
- void *menu_ptr;
-
- switch (menu_id)
- {
- case generalMenusId:
- menu_ptr =
- (void *) explainGeneralMenus; /* V1.2 */
- break;
-
- case generalFormsId:
- menu_ptr =
- (void *) explainGeneralForms; /* V1.2 */
- break;
-
- case selectDirectoryFormId:
- menu_ptr =
- (void *) explainDirNameForm; /* V1.2 */
- break;
-
- case filesMenuId:
- menu_ptr =
- (void *) explainFileMenu; /* V1.2 */
- break;
-
- case browseMenuId:
- menu_ptr =
- (void *) explainBrowserMenu; /* V1.2 */
- break;
-
- case attrMenuId:
- menu_ptr =
- (void *) explainAttrMenu; /* V1.2 */
- break;
-
- case varMenuId:
- menu_ptr =
- (void *) explainVarMenu; /* V1.2 */
- break;
-
- case varDefMenuId:
- menu_ptr =
- (void *) explainAttOfVarMenu; /* V1.2 */
- break;
-
- case attrEntriesMenuId:
- menu_ptr =
- (void *) explainVarOfAttMenu; /* V1.2 */
- break;
-
- case varValMenuId:
- menu_ptr =
- (void *) explainVarValMenu; /* V1.2 */
- break;
-
- case selectRecordFormId:
- menu_ptr =
- (void *) explainRecordNumForm; /* V1.2 */
- break;
-
- case attrEntryElemsMenuId:
- menu_ptr =
- (void *) explainElementsMenu; /* V1.2 */
- break;
-
- default:
- menu_ptr =
- (void *) explainNope; /* V1.2 */
- break;
- } /* end switch */
-
- /* restore saved cursor position */
- saveRow = menu_bar_last_at_row (0);
- saveCol = menu_bar_last_at_col (0);
-
- do /* until keyWas == EXIT */
- {
- keyWas =
- WFL_popup_menu (row, col, SCREEN_HEIGHT,
- " Explanation ",
- menu_ptr,
- &selection, helpInContextMenuId,
- HIGHLIGHT_OFF);
-
- /* Only check interrupt for the QUIT, not HELP or
- * Context-Help, because the help on help
- * may lead to unchecked recursion.
- */
- if (keyWas == KBM_QUIT)
- interrupt_check (keyWas, helpInContextMenuId);
- }
- while (keyWas != KBM_EXIT);
-
- /* restore saved cursor position */
- menu_bar_last_at_row (saveRow);
- menu_bar_last_at_col (saveCol);
-
- return (keyWas);
-
- } /* end explain */
-
-
- void copyrightMenu( row, col)
- int row;
- int col;
- {
- char **menuText;
- int keyWas;
- long int selection;
- int pageLines = SCREEN_HEIGHT+3;
-
- static char banner[] = " Documentary text in CDF header ";
-
- menuText = PTR_LIST_MALLOC( pageLines, char);
- FIXARRAY_MALLOC( menuText, pageLines, char, SCREEN_WIDTH +3);
- CLEAN_PAGE( menuText, pageLines, "");
-
- if (cdf_id == CDF_IS_CLOSED) {
- strcpy( menuText[0],
- " Please open a CDF first to read the documentary text. ");
- } else {
- writemCopyright( menuText);
- }
-
- keyWas = KBM_EXIT +1;
- while (keyWas != KBM_EXIT) {
- keyWas = WFL_popup_menu (row, col, SCREEN_HEIGHT,
- banner, menuText,
- &selection, copyrightMenuId,
- HIGHLIGHT_OFF);
- /* no interrupt check */
- } /* end while */
-
- PTR_LIST_FREE( menuText, pageLines);
- } /* end copyrightMenu */
-
-
- void menuMapMenu( row, col)
- int row;
- int col;
- {
- static char *menuText[] = {
- " ",
- " Browse directory prompt",
- " |",
- " CDF Menu (list of CDFs)",
- " |",
- " ----------------------Browse Menu------------------------",
- " | | | ",
- " Attribute Menu Variable Definitions Menu Variable Values Menu ",
- " | | | ",
- " Entries Menu Variable's Entries Menu Enter Record (Prompt) ",
- " | | | ",
- " Elements List Elements List Variable's Values List ",
- " ",
- "",
- };
- int keyWas;
- long int selection;
- static char banner[] = " Map of CDFbrowse menu structure ";
-
- keyWas = KBM_EXIT +1;
- while (keyWas != KBM_EXIT) {
- keyWas = WFL_popup_menu (row, col,
- SCREEN_HEIGHT,
- banner, menuText,
- &selection, menuMapMenuId,
- HIGHLIGHT_OFF);
- /* no interrupt check */
- } /* end while */
- } /* end menumapMenu */
-
-
- int showMenuKeys (row, col)
- int row;
- int col;
- {
- long int selection;
- static char *menuKeys[] =
- {
- " ",
- " -- function -- -- key to use -- ",
- " KILL the current menu - - - - - - - - - - - - CTRL-K ",
- " Call the main HELP menu - - - - - - - - - - - CTRL-L ",
- " Get HELP-in-context for the current menu - - - CTRL-I ",
- " SELECT the item marked by the menu bar - - - - RETURN (Enter) ",
- " ",
- " EXIT the whole program (go back to VMS) - - - CTRL-E ",
- " ",
- " Move menu bar one LINE UP - - - - - - - - - - Up arrow ",
- " Move menu bar one LINE DOWN - - - - - - - - - Down arrow ",
- " Note: With the arrows, you can wrap-around ",
- " from top-to-bottom of the menu list and vice-versa. ",
- " ",
- " Move menu bar one full menu PAGE UP - - - - - U or Key-Pad 7 ",
- " Move menu bar one full menu PAGE DOWN - - - - D or Key-Pad 4",
- " Note: Use these keys when there are more items in ",
- " a menu than will fit in one window. On the first ",
- " strike of either of the PAGE keys the menu bar will move ",
- " to the top or bottom of the window. Subsequent strikes ",
- " of the same key will show you different pages of the menu ",
- " list, stopping when you reach the menu-top or -bottom. ",
- "",
- };
-
- int keyWas;
-
- do /* until keyWas == EXIT */
- {
- keyWas =
- WFL_popup_menu (row, col, SCREEN_HEIGHT,
- " menu keys ", menuKeys,
- &selection, showMenuKeysMenuId,
- HIGHLIGHT_OFF);
- }
- while (keyWas != KBM_EXIT);
-
- return (keyWas);
-
- } /* end showMenuKeys */
-
-
-
- int showFormKeys (row, col)
- int row;
- int col;
- {
- long int selection;
- static char *formKeys[] =
- {
- " ",
- " -- function -- -- key to use -- ",
- " KILL the current form - - - - - - - - - - - - CTRL-K ",
- " Call the main HELP menu - - - - - - - - - - - CTRL-L ",
- " Get HELP-in-context for the current form - - - CTRL-I ",
- " SELECT (accept) the current item as input and ",
- " move to NEXT input field (if applicable), or, ",
- " SELECT-and-QUIT (in one-item prompt-forms) - RETURN (Enter) ",
- " ",
- " Move to NEXT field (same as SELECT) - - - - - Down-arrow or RETURN ",
- " Move to PREVIOUS field - - - - - - - - - - - - Up-arrow or CTRL-H ",
- " ",
- " EXIT the whole program (go back to VMS) - - - CTRL-E ",
- " ",
- " <more> (press D TWICE) ",
- " ",
- " -- Line editing keys --",
- " ",
- " Move cursor LEFT and RIGHT in the line - - - - Left/Right arrows ",
- " Move cursor to BEGINning of line - - - - - - - CTRL-B or Key-Pad 8 ",
- " Move cursor to END of line - - - - - - - - - CTRL-N or Key-Pad 9 ",
- " ",
- " DELETE one character left of cursor - - - - - Delete (Rubout) ",
- " DELETE LEFT of cursor to start of line - - - - CTRL-X ",
- " DELETE from cursor to end-line inclusive - - - CTRL-D ",
- " ",
- " Toggle between INSERT and OVERWRITE modes - - CTRL-A ",
- " Note: When the program begins OVERWRITE mode is in effect. ",
- " Use INSERT mode to insert text between characters in a line. ",
- "",
- };
-
- int keyWas;
-
- do /* until keyWas == EXIT */
- {
- keyWas =
- WFL_popup_menu (row, col, 15,
- " form keys ", formKeys,
- &selection, showFormKeysMenuId,
- HIGHLIGHT_OFF);
- }
- while (keyWas != KBM_EXIT);
-
- return (keyWas);
-
- } /* end showFormKeys */
-
-
- int helpMenu ( menu_id)
- int menu_id;
- {
- enum menuTrigger { CURRENT, MENU_GEN, MENU_KEYS, FORM_GEN, FORM_KEYS,
- COPYRIGHT, MENU_MAP };
- /* enum order above must match the menu text below */
- static char *mainHelp[] =
- {
- " Explain the current menu or form ",
- " Explain menus in general ",
- " Show menu keys usage ",
- " Explain input forms in general ",
- " Show form keys usage ",
- " Show documentary text in CDF v. 2+ header ",
- " Show a map of CDFbrowse's menu structure ",
- "",
- };
-
- int keyWas;
- long selection;
-
- keyWas = KBM_EXIT +1;
-
- while (keyWas != KBM_EXIT) {
- keyWas = WFL_popup_menu (1, 1,
- SCREEN_HEIGHT,
- " main help ", mainHelp,
- &selection, mainHelpMenuId,
- HIGHLIGHT);
-
- /* Only check interrupt for the QUIT, not HELP or
- * Context-Help, because the help on help
- * may lead to unchecked recursion.
- */
- if (keyWas == KBM_QUIT)
- interrupt_check ( keyWas, mainHelpMenuId);
-
- if (keyWas == KBM_SELECT) {
- switch (selection) {
- case CURRENT: /* explain current item */
- explain ( menu_bar_last_at_row (0) +2,
- menu_bar_last_at_col (0) +2,
- menu_id);
- break;
-
- case MENU_GEN: /* explain menus in general */
- explain (1, 1, generalMenusId);
- break;
-
- case MENU_KEYS: /* menu keys */
- showMenuKeys (1, 1);
- break;
-
- case FORM_GEN: /* explain forms in general */
- explain (1, 1, generalFormsId);
- break;
-
- case FORM_KEYS: /* form keys */
- showFormKeys (1, 1);
- break;
-
- case COPYRIGHT: /* show copyright notice */
- copyrightMenu( 1, 1);
- break;
-
- case MENU_MAP:
- menuMapMenu( 1, 1);
- break;
-
- } /* end switch */
- } /* end if SELECT */
- } /* end while keyWas != EXIT */
-
- return;
-
- } /* end helpMenu */
-
-
-
-
- int select_directory (path_spec)
- char *path_spec;
- {
- /*
- * Select the directory for browsing, return the string in
- * path_spec. Invoke help for the form if requested.
- */
- int keyWas;
- /*int k;*/
-
- do /* until EXIT or NEXTFIELD (SELECT) */
- {
- keyWas = GENERIC_form ("Browse directory: ",
- path_spec, 50, 0, 0);
-
- interrupt_check (keyWas, selectDirectoryFormId);
- }
- while ( (keyWas != KBF_NEXTFIELD) && (keyWas != KBF_EXIT) );
-
- return (keyWas);
-
- } /* end select_directory */
-
-
- void attrEntryElemsMenu(row, col, attrNum, entryNum)
- int row;
- int col;
- long attrNum;
- long entryNum;
- {
- char **menuText;
- static char name[CDF_ATTR_NAME_LEN+1] = "no-name";
- char label[CDF_ATTR_NAME_LEN +SCREEN_WIDTH+1];
- int keyWas;
- long selection;
- /*int j,k;*/
- long pageLines = numElemsAttr( attrNum, entryNum)+5;
-
- menuText = PTR_LIST_MALLOC( pageLines, char);
- FIXARRAY_MALLOC( menuText, pageLines, char, SCREEN_WIDTH);
- CLEAN_PAGE( menuText, pageLines, "");
-
- /* load the menuText; all elements this entry, this attr vertically */
- writemAttrElems( menuText, attrNum, entryNum);
-
- attribName( attrNum, name);
- sprintf (label, " %ld Elements for Entry %ld, Attribute %s ",
- numElemsAttr( attrNum, entryNum), entryNum+1, name);
-
- keyWas = KBM_EXIT +1;
- while (keyWas != KBM_EXIT) {
- keyWas = WFL_popup_menu (row, col,
- SCREEN_HEIGHT, label, menuText,
- &selection, attrEntryElemsMenuId,
- HIGHLIGHT_OFF);
- interrupt_check (keyWas, attrEntryElemsMenuId);
- }
- PTR_LIST_FREE( menuText, pageLines);
- } /* end attrEntryElemsMenu */
-
-
- void varDefMenu (row, col, varNum)
- int row;
- int col;
- long varNum;
- {
- char **menuText;
- static char name[CDF_VAR_NAME_LEN+1] = "no-name";
- char label[CDF_VAR_NAME_LEN +SCREEN_WIDTH+1];
- int keyWas /*,j,k*/ ;
- long selection;
- /*** long pageLines = numVars() +5; ***/ /* V1.1 */
- long pageLines = numAttrs() + 5; /* V1.1 */
-
- menuText = PTR_LIST_MALLOC( pageLines, char);
- FIXARRAY_MALLOC( menuText, pageLines, char, SCREEN_WIDTH);
- CLEAN_PAGE( menuText, pageLines, "");
-
- /* load the menuText */
- writemVarDef( menuText, varNum);
-
- varName(varNum, name);
- sprintf( label, " Attributes of Variable %s ", name);
- keyWas = KBM_EXIT +1;
- while (keyWas != KBM_EXIT) {
- keyWas = WFL_popup_menu (row, col, SCREEN_HEIGHT,
- label, menuText,
- &selection, varDefMenuId,
- HIGHLIGHT);
- interrupt_check (keyWas, varDefMenuId);
-
- if (keyWas == KBM_SELECT && numAttrs() > 0) {
- /* adjust the selection for just the numVarAttrs() */
- long adjustedSelection = nthVarAttr( selection);
- if (adjustedSelection > 0) { /* then it's OK to display */
- attrEntryElemsMenu( menu_bar_last_at_row (0) +1,
- menu_bar_last_at_col (0) +1,
- adjustedSelection, varNum);
- }
- }
- }
- PTR_LIST_FREE( menuText, pageLines);
- } /* end varDefMenu */
-
-
- void varValMenu(row, col, varNum, max_values)
- int row;
- int col;
- long varNum;
- long max_values;
- {
- char **menuText;
- static char name[CDF_VAR_NAME_LEN+1] = "no-name";
- int keyWas /*, j, k*/ ;
- long selection;
- long pageLines = VARVAL_LINES+1;
-
- char label[CDF_VAR_NAME_LEN +SCREEN_WIDTH+1];
- char prompt[CDF_VAR_NAME_LEN +SCREEN_WIDTH+1];
- static char recNumStr[128]="1";
- long recNum;
- /*
- Only malloc what we need
- */
- if(max_values < pageLines)pageLines = max_values+4;
- varName(varNum, name);
- sprintf(prompt, " (%s) Enter record number: ", name);
- menuText = PTR_LIST_MALLOC( pageLines, char);
- FIXARRAY_MALLOC( menuText, pageLines, char,SCREEN_WIDTH +CDF_VAR_NAME_LEN+1);
- CLEAN_PAGE( menuText, pageLines, "");
-
- row = menu_bar_last_at_row (0) +2;
- col = menu_bar_last_at_col (0) +23;
-
- for (;;) { /* FOREVER -- Exit is via KBF_EXIT at the 'Record' prompt */
- do { /* until Form EXIT or NEXTFIELD (SELECT) */
- keyWas = GENERIC_form (prompt,
- recNumStr, 20, row, col-10);
- sscanf(recNumStr, "%ld", &recNum);
- interrupt_check (keyWas, selectRecordFormId);
-
- } while ( (keyWas != KBF_NEXTFIELD) && (keyWas != KBF_EXIT) );
-
- /* HERE IS THE ONLY NORMAL RETURN POSSIBLE */
- if (keyWas == KBF_EXIT)
- {
- PTR_LIST_FREE( menuText, pageLines);
- return;
- }
-
- CLEAN_PAGE( menuText, pageLines, "");
- /* load the menuList */
- writemVarVals( menuText, varNum, recNum-1, pageLines);
-
- sprintf (label, " Values of the Variable %s ", name);
- keyWas = KBM_EXIT +1;
- while (keyWas != KBM_EXIT) {
- keyWas = WFL_popup_menu (row, col, SCREEN_HEIGHT,
- label, menuText,
- &selection, varValMenuId,
- HIGHLIGHT_OFF);
- interrupt_check (keyWas, varValMenuId);
- }
- } /* end FOREVER loop */
-
-
- } /* end varValMenu */
-
-
- void varMenu (vtype, max_values)
- long vtype;
- long max_values;
- {
- char **menuText;
- static char *titleText[] = {
- " name type record [dimension] variances ",
- "",};
- struct window_struct *titleWindow;
- int keyWas;
- long selection;
- /*int j,k;*/
- long pageLines = numVars()+2;
-
- char banner[SCREEN_WIDTH+1];
-
- menuText = PTR_LIST_MALLOC( pageLines, char);
- FIXARRAY_MALLOC( menuText, pageLines, char,SCREEN_WIDTH +CDF_VAR_NAME_LEN+1);
- CLEAN_PAGE( menuText, pageLines, "");
-
- /* load the menuText with the variables list */
- writemVars( menuText);
-
- switch( vtype) {
- case VARDEF:
- sprintf(banner," %ld Variables (Select for attributes ) ",numVars());
- break;
- case VARVAL:
- sprintf(banner," %ld Variables (Select for data values) ",numVars());
- break;
- }
- WFL_popup_info (VARMEN_ROW, VARMEN_COL,
- SCREEN_HEIGHT,
- banner,
- titleText, &titleWindow);
-
- keyWas = KBM_EXIT +1;
- while (keyWas != KBM_EXIT) {
- keyWas = WFL_popup_menu (VARMEN_ROW+2, VARMEN_COL,
- VARMEN_HT, "", menuText,
- &selection, varMenuId,
- HIGHLIGHT);
-
- interrupt_check (keyWas, varMenuId);
-
- if (keyWas == KBM_SELECT && numVars() > 0)
- switch (vtype) {
- case VARDEF:
- varDefMenu (menu_bar_last_at_row (0) +2,
- menu_bar_last_at_col (0) +2,
- selection);
- break;
-
- case VARVAL:
- varValMenu (menu_bar_last_at_row (0) +2,
- menu_bar_last_at_col (0) +22,
- selection, max_values);
- break;
- } /* end switch */
- } /* end while */
- WFL_erase_window (titleWindow);
- WFL_delete_dyna_window (titleWindow);
- PTR_LIST_FREE( menuText, pageLines);
- } /* end varMenu */
-
-
-
-
-
-
- void attrEntriesMenu ( row, col, attrNum)
- int row;
- int col;
- long attrNum;
- {
- /* nov-1990, this menu changes to a selection-menu for entries. -dg. */
- char **menuText;
- static char name[CDF_ATTR_NAME_LEN+1] = "no-name";
- char label[CDF_ATTR_NAME_LEN +SCREEN_WIDTH+1];
- int keyWas;
- long selection;
- /*int j,k;*/
- long pageLines = maxAttrEntry( attrNum)+5;
-
- menuText = PTR_LIST_MALLOC( pageLines, char);
- FIXARRAY_MALLOC( menuText, pageLines, char, SCREEN_WIDTH+2);
- CLEAN_PAGE( menuText, pageLines, "");
-
- /* load the menuText */
- writemAttrEntries( menuText, attrNum);
-
- attribName(attrNum, name);
- sprintf (label, " %ld Entries for Attribute %s ",
- maxAttrEntry( attrNum)+1, name);
- keyWas = KBM_EXIT +1;
- while (keyWas != KBM_EXIT) {
- keyWas = WFL_popup_menu (row, col,
- SCREEN_HEIGHT, label, menuText,
- &selection, attrEntriesMenuId,
- HIGHLIGHT);
-
- interrupt_check (keyWas, attrEntriesMenuId);
-
- if (keyWas == KBM_SELECT) {
- attrEntryElemsMenu( menu_bar_last_at_row (0) +1,
- menu_bar_last_at_col (0) +1,
- attrNum, selection);
- }
- }
- PTR_LIST_FREE( menuText, pageLines);
-
- } /* end attrEntriesMenu */
-
-
- void attrMenu ()
- {
- char **menuText;
- static char *titleText[] =
- {" name entries scope ", "", };
- struct window_struct *titleWindow;
- int keyWas;
- long selection;
- /*int j,k;*/
- long pageLines = numAttrs()+5;
- char banner[SCREEN_WIDTH+1];
-
- menuText = PTR_LIST_MALLOC( pageLines, char);
- FIXARRAY_MALLOC( menuText, pageLines, char, SCREEN_WIDTH);
- CLEAN_PAGE( menuText, pageLines, "");
-
- /* load the attribute menu list */
- writemAttrs( menuText);
- sprintf (banner, " %ld Attributes ", numAttrs() );
-
- WFL_popup_info (ATTMEN_ROW, ATTMEN_COL, SCREEN_HEIGHT,
- banner, titleText, &titleWindow);
-
- keyWas = KBM_EXIT +1;
- while (keyWas != KBM_EXIT) {
- keyWas = WFL_popup_menu (ATTMEN_ROW+2, ATTMEN_COL,
- ATTMEN_HT,"", menuText,
- &selection, attrMenuId,
- HIGHLIGHT);
- interrupt_check (keyWas, attrMenuId);
-
- if (keyWas == KBM_SELECT && numAttrs() > 0) {
- attrEntriesMenu (menu_bar_last_at_row (0) +1,
- menu_bar_last_at_col (0) +1,
- selection);
- }
- }
- WFL_erase_window (titleWindow);
- WFL_delete_dyna_window (titleWindow);
- PTR_LIST_FREE( menuText, pageLines);
-
- } /* end attrMenu */
-
-
- void browseMenu (max_values)
- long max_values;
- {
- static char *browseList[]=
- {
- " Attribute Definitions ",
- " Variable Definitions ",
- " Variable Values ",
- "",
- };
- int keyWas;
- long selection;
- /*int j,k;*/
- /* cdf_id is static global integer */
-
- keyWas = KBM_EXIT +1;
-
- while (keyWas != KBM_EXIT)
- {
- keyWas = WFL_popup_menu ( 4, 59-COL_OFFSET,
- SCREEN_WIDTH, " Browser ",
- browseList,
- &selection,
- browseMenuId,
- HIGHLIGHT);
-
- interrupt_check (keyWas, browseMenuId);
-
- if (keyWas == KBM_SELECT)
- switch (selection) {
- case 0:
- attrMenu ();
- break;
- case 1:
- varMenu (VARDEF, max_values);
- break;
- case 2:
- varMenu (VARVAL, max_values);
- break;
- } /* end select for browse Menu selection */
-
- } /* end while keyWas != KBM_EXIT */
- } /* end browseMenu */
-
- #if defined(vms)
- main (argc, argv)
- #else
- void main (argc, argv)
- #endif
- int argc;
- char *argv[];
- {
- struct main_struct {
- char *GLOBAL_cont;
- char *MESS_MENU_cont;
- } m;
- struct window_struct *onscreen_help_window;
-
- static char *onscreen_help[] = {
- " Kill window: CTRL-K Select: RETURN Explain: CTRL-I main HELP:CTRL-L ",
- "",
- };
- static char *filenotfound[] = {
- " No CDFs in the directory, ",
- " no such directory, or ",
- " the directory is protected. ",
- "",
- };
-
- char file_spec[MAXNAMELEN+1];
- char path_spec[MAXNAMELEN+1];
- char **file_names = NULL;
- char **directory = NULL;
-
- char **titlePage = NULL;
- struct window_struct *cdfTitleWindow;
-
- char **headerPage = NULL;
- struct window_struct *cdfHeaderWindow;
-
- /*struct window_struct *infoWindow;*/
- long selection;
- long max_values;
-
- int nfiles, keyWas, program_status, /*scancode,*/ /*k,*/ resp;
- char message[512], fileMenuBanner[512] /*, clearstring[512]*/ ;
- char **WFLlist;
- QOP *qop;
- static char *validQuals[] = { NULL };
-
- /******************************************************************************
- * Default directories (if none specified on command line).
- ******************************************************************************/
- #if defined(unix)
- static char curr_dir[] = "./*.cdf" ;
- #else
- #if defined(__MSDOS__)
- static char curr_dir[] = ".\\*.cdf";
- #else
- #if defined(vms)
- static char curr_dir[] = "[]*.cdf";
- #endif
- #endif
- #endif
- /*char temp[CDF_PATHNAME_LEN];*/
-
- #if defined(unix) /* V1.3 */
- strcpy(path_spec, "./"); /* V2.1 should have this for default directory */
- #endif
-
- #if defined(vms)
- strcpy (path_spec, "[]");
- #endif
-
- #if defined(__MSDOS__)
- strcpy(path_spec,".");
- #endif
-
- /******************************************************************************
- * Get qualifiers/options/parameters.
- ******************************************************************************/
-
- qop = Qop (argc, argv, validQuals, NULL);
- if (qop == NULL) ExitBAD;
-
- switch (qop->Nparms) {
- case 0:
- break;
- case 1:
- strcpy (path_spec, qop->parms[0]);
- break;
- default:
- printf ("Too many parameters.\n");
- ExitBAD;
- }
- #if NSSDC_STANDARD /* V1.4 */
- titlePage = PTR_LIST_MALLOC( TITLE_LINES, char);
- FIXARRAY_MALLOC( titlePage, TITLE_LINES, char, SCREEN_WIDTH);
- CLEAN_PAGE( titlePage, TITLE_LINES, "");
- #endif
-
- headerPage = PTR_LIST_MALLOC( HEADER_LINES, char);
- FIXARRAY_MALLOC( headerPage, HEADER_LINES, char, SCREEN_WIDTH);
-
- /* these are used to clear message window the hard way */
- /* for (k=0; k<157; k++) clearstring[k] = ' ';
- clearstring[77] = '\n';
- clearstring[78] = '\r';
- clearstring[156] = '\0';*/
-
- /* Initialize the user interface */
- WFL_init ();
-
- /*
- * This will put the bottom of the help box 3 lines above
- * the screen bottom, flush left.
- */
- WFL_popup_info (SCREEN_HEIGHT -string_count(onscreen_help) -1, 1,
- SCREEN_HEIGHT,
- "",
- onscreen_help, &onscreen_help_window);
-
- /* Initialize message window */
- MESS_init ((struct mess_menu_struct **) &m.MESS_MENU_cont);
- MESS_draw ((struct mess_menu_struct * )m.MESS_MENU_cont);
- if (qop->Nparms != 1) {
- char bannerText[80+1];
- sprintf (bannerText, " CDFbrowse, CDF Version %ld.%ld.%ld distribution.",
- CDF_LIBRARY_VERSION, CDF_LIBRARY_RELEASE, CDF_LIBRARY_INCREMENT);
- MESS_display (bannerText, NOBEEP);
- }
-
- /* ----------------- End of all preliminaries ---------- */
- if (qop->Nparms != 1)
- program_status = select_directory (path_spec);
- else
- program_status = KBF_SELECT;
- if(strlen(path_spec) == 0)
- strcpy(file_spec, curr_dir);
- else
- BuildSearchSpec (path_spec, file_spec);
-
- while (program_status != KBF_EXIT) {
- if (IsDir(path_spec))
- sprintf (message, " Browsing directory >> %s", path_spec);
- else
- sprintf (message, " Browsing CDF >> %s", path_spec);
-
- MESS_erase_display((struct mess_menu_struct *) m.MESS_MENU_cont);
- MESS_display (message, NOBEEP);
-
- nfiles = DirList (file_spec, &directory, &file_names);
-
-
- keyWas = KBM_EXIT +1;
- while (keyWas != KBM_EXIT) {
-
- if (nfiles > 0) { /* if there are files, popup the list */
- sprintf (fileMenuBanner, "%3d CDFs ", nfiles);
- RemoveExtensions(nfiles, file_names);
- if(nfiles > 1)
- {
- BuildWFLlist (nfiles, file_names, &WFLlist);
- keyWas = WFL_popup_menu (1, 80, 10,
- fileMenuBanner, WFLlist,
- &selection, filesMenuId, HIGHLIGHT);
- FreeWFLlist (WFLlist);
- interrupt_check (keyWas, filesMenuId);
- }
- else
- {
- selection = 0;
- keyWas = KBM_SELECT;
- }
-
- if (keyWas == KBM_SELECT) {
- CLEAN_PAGE( headerPage, HEADER_LINES, "");
- /*
- if only 1 cdf was entered, this will make the user enter another path_spec
- */
- if (nfiles == 1)keyWas = KBM_EXIT;
-
- cdf_id = openCDFtoBrowse (directory[selection],
- file_names[selection],
- headerPage, &max_values);
-
- switch( cdf_id) {
- case 0: /* an error. Show message and wait */
- WFL_popup_info (HEADER_ROW, HEADER_COL,
- SCREEN_HEIGHT,
- " no-can-do ",
- headerPage, &cdfHeaderWindow);
- /* pause and show error, using dummy assign statement
- warning message on PC */
- resp = getchar ();
- selection = resp;
- break;
-
- default: /* a CDF is loaded; display the header */
- #if NSSDC_STANDARD /* V1.4 */
- writemTitle (titlePage);
- WFL_popup_info (TITLE_ROW, TITLE_COL,
- SCREEN_HEIGHT,
- "",
- titlePage, &cdfTitleWindow);
- #endif
- WFL_popup_info (HEADER_ROW, HEADER_COL,
- SCREEN_HEIGHT,
- " Header ",
- headerPage, &cdfHeaderWindow);
- browseMenu (max_values);
- #if NSSDC_STANDARD /* V1.4 */
- WFL_erase_window (cdfTitleWindow);
- WFL_delete_dyna_window (cdfTitleWindow);
- #endif
- cdfCloseQuit ();
- cdf_id = CDF_IS_CLOSED;
- break;
- } /* end switch */
- WFL_erase_window (cdfHeaderWindow);
- WFL_delete_dyna_window (cdfHeaderWindow);
-
- } /* end if KBM_SELECT a file name */
-
- } else { /* number of files == 0 */
- /* No CDF files on the directory -- inform user */
- keyWas = WFL_popup_menu (12, 16, 12,
- file_spec, filenotfound,
- &selection, filenotfoundMenuId,
- HIGHLIGHT_OFF);
- interrupt_check (keyWas, filenotfoundMenuId);
- }
- } /* end while keyWas != KBM_EXIT */
-
- /* free the file_names list */
- if(file_names != NULL)free (file_names);
- if(directory != NULL) free (directory);
-
- /* Select the browse directory again for the next cycle */
- program_status = select_directory (path_spec);
- if(strlen(path_spec) == 0)
- strcpy(file_spec, curr_dir);
- else
- BuildSearchSpec (path_spec, file_spec);
-
- } /* end while program_status != KBF_EXIT */
-
- #if NSSDC_STANDARD /* V1.4 */
- PTR_LIST_FREE( titlePage, TITLE_LINES);
- #endif
-
- PTR_LIST_FREE( headerPage, HEADER_LINES);
-
- exitProgram();
- } /* end main */